package com.atguigu.gmall.gmallpublisher.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * ClassName: SugarMapper
 * Package: com.atguigu.gmall.gmallpublisher.mapper
 * Description:
 *
 * @Author ChenJun(有志男青年)
 * @Create 2023/5/13 11:39
 * @Version 1.0
 */
@Mapper
public interface SugarMapper {

    /**
     * 查询支付总额
     * @param date
     * @return
     */
    @Select("select sum(order_amount) order_amount from dws_trade_sku_order_window where toYYYYMMDD(stt)=${date}")
    BigDecimal selectGmv(int date);

    /**
     * 通过tm查询前几的支付金额
     * @param date   日期
     * @param limit  前几
     * @return
     */ 
    @Select("select trademark_name,sum(order_amount) order_amount,count(*) ct from dws_trade_sku_order_window where " +
            "toYYYYMMDD(stt)=${date} group by trademark_name order by order_amount desc limit ${limit}")
    List<Map<String,Object>> selectGmvByTm(@Param("date") int date, @Param("limit") int limit);

}
